﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.ComponentModel;

namespace WMSSoft.Lib.Basic
{
    public static class EnumUtils
    {
        public static string GetEnumValueDesc(Enum enumValue, string Default)
        {

            FieldInfo fi = enumValue.GetType().GetField(enumValue.ToString());
            object[] attrs = fi.GetCustomAttributes(typeof(DescriptionAttribute), true);
            if (attrs != null && attrs.Length > 0)
                return ((DescriptionAttribute)attrs[0]).Description;
            else
                return Default;
        }
    }
}
